/*
 * instack.c
 *
 *  Created on: 2009-5-14
 *      Author: hwg
 */

#include "../header/common.h"

void ininitian(instack * s)
{
	s->top = 0;
}

int inpush(instack * s , int n)
{
	if(sizeof(s->stack) >= s->top)
	{
		s->stack[s->top] = n;
		s->top = s->top + 1;
		return 1;
	}
	else
		return  -1;

}
int inpop(instack *s)
{
	if( s->top > 0)
	{
		s->top = s->top - 1;
		return (s->stack[s->top]);
	}
	else
	{
		return -1;
	}
}

int ingettop(instack *s)
{
	if(s->top >=0)
		{
			return s->stack[s->top - 1];
		}
		else
			return  -1;
}
